package com.sumainfor.pc.market.controller.gmio;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.market.service.gmio.PayPactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 功能描述:
 *
 * @Auther: zhlu
 * @Date: 2019/3/27 17:32
 * @Description:
 */
@RestController
@RequestMapping("/key/pact")
public class PayPactController {

    @Autowired
    PayPactService PayPactService;

    /**
     * 功能描述: 
     * 首月支付完成之后修改合同状态为已支付
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/3/27 17:44
     */
    @ResponseBody
    @PostMapping("/UpdatePayPact")
    public JsonResult UpdatePayPact(@RequestBody Map<String,Object> params){
        JsonResult result=new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"PaId"})){
            result.putFailed("PaId不能为空！");
            return  result;
        }
        if(PayPactService.UpdatePayPact(params)){
            result.putSuccess("合同修改成功！");
        }else{
            result.putFailed("服务器繁忙，请稍后重试！");
        }
        return result;
    }

    /**
     * 功能描述: 
     * 根据账单资料来源编号获取合同资料
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/4/28 14:59
     */
    @GetMapping("/getTrenantBillPact")
    public JsonResult getTrenantBillPact(@RequestParam Map<String,Object>params){
        JsonResult result=new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"Source"})){
            result.putFailed("Source不能为空！");
            return  result;
        }
        return result.put(PayPactService.getTrenantBillPact(params));
    }

}
